package com.dragon.blelibrary;


import android.content.Context;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Handler;


public class BleConfig {
	/**是否将蓝牙日志写入文件*/
	public static boolean writeBleToFile = true;
	public static Context mContext;
	public static Handler mHandler;
	/**是否向控制台打印log，1是，0否 */
	public static String debugLog = "1";
	/**SD卡文件根目录名称*/
	public static String rootFile = "dragon";
	/**app版本名称*/
	public static String versionName;
	public static void init(Context ctx, Handler h, String rf){
		rootFile = rf;
		mContext = ctx;
		mHandler = h;
		versionName = getAppVersionName(mContext);
	}
	/**
	 * 返回当前程序版本名
	 */
	private static String getAppVersionName(Context context) {
		String versionName = "";
		try {
			// ---get the package info---
			PackageManager pm = context.getPackageManager();
			PackageInfo pi = pm.getPackageInfo(context.getPackageName(), 0);
			versionName = pi.versionName;
			int versioncode = pi.versionCode;
			if (versionName == null || versionName.length() <= 0) {
				return "";
			}
		} catch (Exception e) {
		}
		return versionName;
	}
	public static void onDistory(){
	}
}
